package com.mojo.concurrent.concurrent_01_thread;

/**
 * ThreadLocal应用
 *
 * @author <a href="mailto:sjj@jianzhimao.com">mojo</a>
 * copyright (C), 2013-2023, 广州九尾信息科技有限公司
 * @date 2023/2/1 20:51
 */
public class Profiler {
    static ThreadLocal<Long> t = ThreadLocal.withInitial(System::currentTimeMillis);

    public static void begin() {
        t.set(System.currentTimeMillis());
    }

    public static long interval() {
        return System.currentTimeMillis() - t.get();
    }
}
